//
//  ViewController.m
//  11104
//
//  Created by student on 16/2/29.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    for (int i =0; i<10; i++) {
        UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(10+45*i, 20, 45, 30)];
        [button setTitle:[NSString stringWithFormat:@"新闻%i",i] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
        button.titleLabel.font=[UIFont systemFontOfSize:15];
        [self.scrollView addSubview:button];
        [button addTarget:self action:@selector(print) forControlEvents:UIControlEventTouchUpInside];
        self.scrollView.showsHorizontalScrollIndicator=NO;
        
    }
    self.scrollView.backgroundColor=[UIColor blackColor];
    self.scrollView.contentSize=CGSizeMake(500, 30);
    [self.view addSubview:self.scrollView];
}
-(void)print
{
    NSLog(@".");
}

@end
